import {ApiProperty} from "@nestjs/swagger";
import {PageVo} from "./page.vo";

export class PageResVo<T>{
    @ApiProperty({example:"1", description:"当前页"})
    page:number
    @ApiProperty({example:"10", description:"每页条数"})
    size: number
    @ApiProperty({example:"100", description:"总条数"})
    totalCount:number
    @ApiProperty({example:"[]", description:"数据"})
    data: T[]

    static generatePage<T extends PageVo,E>(queryProductVo: T, total: number, resData: E[]) {
        let pageResVo = new PageResVo<E>()
        pageResVo.page = queryProductVo.page
        pageResVo.size = queryProductVo.size
        pageResVo.totalCount = total
        pageResVo.data = resData
        return pageResVo;
    }
}